﻿@model  List<ElingOA6_Admin_DSJCJ.Model.Calendar>
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
@Html.Partial("LoadPanelPartial")
<head>
@* <meta http-equiv="X-UA-Compatible" content="IE=7" />*@
    <title>RemindersFormPartial</title>
    @if (false)
    {
    
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/My97DatePicker/WdatePicker.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui.min.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/regex.js", true)" type="text/javascript"></script>
    @Html.DevExpress().GetStyleSheets(

                new StyleSheet { ExtensionType = ExtensionType.Button, Theme = DevExpressHelper.Theme },
                        new StyleSheet { ExtensionType = ExtensionType.PopupControl, Theme = DevExpressHelper.Theme },
                          new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }


)
    @Html.DevExpress().GetScripts(
             new Script { ExtensionType = ExtensionType.ListBox },

                            new Script { ExtensionType = ExtensionType.PopupControl },
                             new Script { ExtensionType = ExtensionType.Button }

    )
    <script type="text/javascript">

        $(document).ready(function () {
            myInterval();
            setInterval("myInterval()", 60000);


            var hdjsAlert = $("#hdjsAlert").val();


            if (hdjsAlert != "" & hdjsAlert != null) {
                alert(hdjsAlert);
            }
        });
        function myInterval() {

            $.ajax({
                type: "POST",
                url: '@Url.Content("~/Admin/Calendar/needremind")',
                data: {},
                dataType: "json",
                error: function (data) {
                    // ASPxClientPopupControl.Cast("popfirst").Hide();
                    // alert(data.toString());
                    parent.closepop()
                },
                success: function (data) {

                    var ctrl = ASPxClientListBox.Cast("FTitles");
                    //  lp.Show();
                    ctrl.BeginUpdate();
                    ctrl.ClearItems();
                    if (data.length == 0) {
                        // ASPxClientPopupControl.Cast("popfirst").Hide();
                        parent.closepop()
                        return;
                    }
                    else {
                        for (var i = 0; i < data.length; i++) {
                            ctrl.AddItem([data[i].FTitle, data[i].ExpireStr], data[i].FCalendarID);
                        }
                    }
                    ctrl.EndUpdate();
                    //  lp.Hide();
                    // ASPxClientPopupControl.Cast("popfirst").Show();
                    //是否显示窗口***
                    parent.openshow();
                }
            });
        }
        function updatermdpopup(data) {
 
        }
        //取消选择项
        function dismissone() {
            $("#htype").val("1");
            // form_query.submit();
            $.ajax({
                type: "POST",
                url: '@Url.Action("SaveRemind", "Calendar")',
                data: $('#form_query').serialize(),
                dataType: "json",
                error: function (data) {
                    alert(data.responseText);
                },
                success: function (data) {
                    codeOK(data);
                }
            });
        }
        //取消全部
        function dismissall() {
            $("#htype").val("2");
            //  form_query.submit();
            $.ajax({
                type: "POST",
                url: '@Url.Action("SaveRemind", "Calendar")',
                data: $('#form_query').serialize(),
                dataType: "json",
                error: function (data) {
                    alert(data.responseText);
                },
                success: function (data) {
                    codeOK(data);
                }
            });
        }
        //推迟
        function snoozenows() {
            $("#htype").val("0");

            $.ajax({
                type: "POST",
                url: '@Url.Action("SaveRemind", "Calendar")',
                data: $('#form_query').serialize(),
                dataType: "json",
                error: function (data) {
                    alert(data.responseText);
                },
                success: function (data) {

                    codeOK(data);


                }
            });

        }
        //ajax生成下拉框
        function sectchg() {
            var ctrl = ASPxClientListBox.Cast("FTitles");
            var lstval = ctrl.GetSelectedValues()[0];
            $.ajax({
                type: "POST",
                url: '@Url.Action("GetComboboxList", "Calendar")',
                data: { cval: lstval },
                dataType: "json",
                error: function (data) {
                    alert(data.responseText);
                },
                success: function (data) {

                    ASPxClientComboBox.Cast("rmdcombobox").ClearItems();
                    for (var i = 0; i < data.length; i++) {
                        ASPxClientComboBox.Cast("rmdcombobox").AddItem(data[i].Text, data[i].Value);
                    }
                    var im = ASPxClientComboBox.Cast("rmdcombobox").FindItemByValue("5m");
                    
                    ASPxClientComboBox.Cast("rmdcombobox").SetSelectedItem(im);
                }
            });

        }
        function codeOK(data) {


            //动态添加数据
            var ctrl = ASPxClientListBox.Cast("FTitles");
            lp.Show();
            ctrl.BeginUpdate();
            ctrl.ClearItems();
            if (data.length == 0) {
                // ASPxClientPopupControl.Cast("popfirst").Hide();

                parent.closepop()
                return;
            }
            else {
                for (var i = 0; i < data.length; i++) {
                    ctrl.AddItem([data[i].FTitle, data[i].ExpireStr], data[i].FCalendarID);
                }
            }
            ctrl.EndUpdate();
            lp.Hide();
        }

    </script>
</head>
<body>
    @using (Html.BeginForm("SaveRemind", "Calendar", FormMethod.Post, new { id = "form_query" }))
    {
        @Html.Hidden("htype", "");
        <table style="width: 502px; border-collapse: collapse;" cellspacing="0" cellpadding="0">
            <tr>
                <td style="height: 150px; margin-top: 0px;">
                    @Html.DevExpress().ListBox(
             settings =>
             {
                 settings.Name = "FTitles";
                 // settings.Properties.TextField = "Subject";
                 settings.Properties.ValueField = "FCalendarID";
                 settings.Properties.ValueType = typeof(string);
                 settings.Properties.EnableClientSideAPI = true;
                 settings.SelectedIndex = 0;
                 settings.Properties.SelectionMode = ListEditSelectionMode.Single;
                 settings.Properties.ClientSideEvents.SetEventHandler("ItemDoubleClick", "function(s, e){parent.chgid(s,e);}");
                 settings.Properties.Columns.Add("FTitle", "主题").Width = System.Web.UI.WebControls.Unit.Percentage(80);
                 settings.Properties.ClientSideEvents.SelectedIndexChanged = "sectchg";
                 settings.Properties.Columns.Add("ExpireStr", "到期时间").Width = System.Web.UI.WebControls.Unit.Percentage(20);
                 settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                 settings.Height = System.Web.UI.WebControls.Unit.Pixel(150);
             }).BindList(Model).GetHtml()
                </td>
            </tr>
            <tr style="background-color: #B6D6FF">
                <td>
                    <div style="width: 100%">
                        <div style="float: left; margin-left: 5px;">
                            @Html.DevExpress().Button(
                           settings =>
                           {
                               settings.Name = "disall";
                               settings.Text = "全部消除";
                               settings.Height = System.Web.UI.WebControls.Unit.Pixel(20);
                               settings.Width = System.Web.UI.WebControls.Unit.Pixel(80);
                               settings.ClientSideEvents.Click = "dismissall";
                           }
                           ).GetHtml()</div>
                        <div style="float: right; margin-right: 11px;">
                            @Html.DevExpress().Button(
                           settings =>
                           {
                               settings.Name = "disone";
                               settings.Text = "消除";
                               settings.Height = System.Web.UI.WebControls.Unit.Pixel(20);
                               settings.Width = System.Web.UI.WebControls.Unit.Pixel(70);
                               settings.ClientSideEvents.Click = "dismissone";
                           }
                           ).GetHtml()</div>
                    </div>
                </td>
            </tr>
            <tr style="background-color: #B6D6FF">
                <td>
                    <table style="width: 100%; border-collapse: collapse; margin-left: 2px; padding-bottom: 15px;
                        overflow: visible; height: 46px;">
                        <tr>
                            <td colspan="4" style="margin-left: 10px">
                                @Html.DevExpress().ComboBox(
                settings =>
                {
                    settings.Name = "rmdcombobox";
                    settings.Properties.TextField = "Text";
                    settings.Properties.ValueField = "Value";
                    settings.Width = System.Web.UI.WebControls.Unit.Pixel(350);
                    settings.Height = System.Web.UI.WebControls.Unit.Pixel(20);
                    settings.Properties.EnableClientSideAPI = true;

                }).BindList(new List<SelectListItem> { 
                         
                           new SelectListItem { Text = "0分钟", Value = "0m" },

                           new SelectListItem { Text = "5分钟", Value = "5m" },
                           new SelectListItem { Text = "10分钟", Value = "10m" },
                           new SelectListItem { Text = "15分钟", Value = "15m" },
                           new SelectListItem { Text = "30分钟", Value = "30m" },
                           new SelectListItem { Text = "1小时", Value = "1h" },
                             new SelectListItem { Text = "3小时", Value = "3h" },
                               new SelectListItem { Text = "5小时", Value = "5h" },
                                 new SelectListItem { Text = "10小时", Value = "10h" },
                                  new SelectListItem { Text = "1天", Value = "1d" },
                                   new SelectListItem { Text = "2天", Value = "2d" },
                                    new SelectListItem { Text = "3天", Value = "3d" },
                                     new SelectListItem { Text = "5天", Value = "5d" },
                                     new SelectListItem { Text = "10天", Value = "5d"} 
     }).Bind("5m").GetHtml()
                            </td>
                            <td>
                                <div style="float: right; margin-right: 12px;">
                                    @Html.DevExpress().Button(
                           settings =>
                           {
                               settings.Name = "snoozen";
                               settings.Text = "推迟";
                               settings.Height = System.Web.UI.WebControls.Unit.Pixel(20);
                               settings.Width = System.Web.UI.WebControls.Unit.Pixel(70);
                               settings.ClientSideEvents.Click = "snoozenows";
                           }
                           ).GetHtml()</div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    }
</body>
</html>
